using System;

namespace ERP.ERPSystem.WarehouseManagement.Dto
{
    /// <summary>
    /// 来料检验DTO
    /// </summary>
    public class IncomingInspectionDto
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 来料检验单编号
        /// </summary>
        public string IncomingInspectionCode { get; set; }

        /// <summary>
        /// 来料检验单名称
        /// </summary>
        public string IncomingInspectionName { get; set; }

        /// <summary>
        /// 供应商简称
        /// </summary>
        public string IncomingInspectionJName { get; set; }

        /// <summary>
        /// 供应商批次号
        /// </summary>
        public string Batch { get; set; }

        /// <summary>
        /// 产品物料编号
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 产品物料名称
        /// </summary>
        public string ProductName { get; set; }

        /// <summary>
        /// 接收数量
        /// </summary>
        public int? ReceiveNum { get; set; }

        /// <summary>
        /// 检测数量
        /// </summary>
        public int? TestingNum { get; set; }

        /// <summary>
        /// 不合格数
        /// </summary>
        public int? UnqualifiedNum { get; set; }

        /// <summary>
        /// 检测结果
        /// </summary>
        public string TestingResult { get; set; }

        /// <summary>
        /// 来料日期
        /// </summary>
        public DateTime IncomingDate { get; set; }

        /// <summary>
        /// 检测日期
        /// </summary>
        public DateTime TestingDate { get; set; }

        /// <summary>
        /// 检测人员
        /// </summary>
        public string TestingPerson { get; set; }

        /// <summary>
        /// 单据状态 (0=草稿，1=已确认，2=已完成)
        /// </summary>
        public int? State { get; set; }

        /// <summary>
        /// 状态文本
        /// </summary>
        public string StateText { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 合格率（计算属性）
        /// </summary>
        public decimal? QualifiedRate
        {
            get
            {
                if (TestingNum.HasValue && TestingNum.Value > 0)
                {
                    var qualifiedNum = TestingNum.Value - (UnqualifiedNum ?? 0);
                    return Math.Round((decimal)qualifiedNum / TestingNum.Value * 100, 2);
                }
                return null;
            }
        }
    }
} 